package ee.ut.veebirakendus.model;

public class Card {

	private final Suit suit;
	private final Rank rank;
	
	public Card(){
		this.suit=null;
		this.rank=null;
	}
	public Card(Suit suit, Rank rank) {
		this.suit = suit;
		this.rank = rank;
	}

	public Suit getSuit() {
		return suit;
	}

	public Rank getRank() {
		return rank;
	}

	public String getShort() {
		StringBuilder builder = new StringBuilder();
		builder.append(getRank().rank()).append(getSuit().suit());
		return builder.toString();
	}
	public int getInt() {
		
		int rankInt = 0;
		try {
			 rankInt = Integer.parseInt(this.getRank().rank());
		} catch(NumberFormatException e) {
			if(this.getRank()==Rank.TEN) {
				rankInt = 10;
			}
			else if(this.getRank()==Rank.JACK) {
				rankInt = 11;
			}
			else if(this.getRank()==Rank.QUEEN) {
				rankInt = 12;
			}
			else if(this.getRank()==Rank.KING) {
				rankInt = 13;
			}
			else if(this.getRank()==Rank.ACE) {
				rankInt = 14;
			}
		}
		return rankInt;
	}

	@Override
	public String toString() {
		return getSuit().name() + " " + getRank().name();
	}
	
}
